package main

import (
	"fmt"
	"math/rand"
)

type animal interface {
	move() int
	eat() string
}

type movement struct {
	maxStep, minStep int
}

func (m movement) move() int {
	return rand.Intn(m.maxStep-m.minStep) + m.minStep
}

type eats struct {
	fruits []string
}

func (e eats) eat() string {
	return e.fruits[rand.Intn(len(e.fruits))]
}

type Animal struct {
	name string
	movement
	eats
}

func (a Animal) String() string {
	return fmt.Sprintf("%v", a.name)
}

func initAnimal(name string, maxStep, minStep int, fruits []string) Animal {
	return Animal{name, movement{maxStep, minStep}, eats{fruits}}
}

func animalAct(a animal) {
	fmt.Println("move", a.move())
	fmt.Println("eat", a.eat())
}

func main() {
	animal1 := initAnimal("wk", 10, 0, []string{"11", "22", "33"})
	animalAct(animal1)
}
